package ex4.gui;
import javax.swing.*;

import ex4.logic.Configuration;
import ex4.logic.IceAgeSnake;
import ex4.logic.Ornamental;
import ex4.logic.Snake;

import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.*;


public class Game extends JFrame implements ActionListener {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private Board board;
	
	
	public Game(Snake snake){

		super("Snake");
		this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		
		getContentPane().setLayout(new BorderLayout());
		JButton stopButton = new JButton("Stop Game");
		stopButton.addActionListener(this);
		this.board = new Board(snake , this);		
		board.setBackground(Color.BLACK);	
		
		board.addKeyListener(board);
		board.setFocusable(true);
		this.setSize(800,600);
		this.getContentPane().add(stopButton, BorderLayout.NORTH);
		this.getContentPane().add(board, BorderLayout.CENTER);
		
		this.pack();
		board.requestFocus();
		this.setSize(800,600);
		this.setVisible(true);

		/*
		getContentPane().setLayout(new BorderLayout());
		JButton nextButton = new JButton("Stop Game");
		this.board = new Board(snake);
		board.setBackground(Color.BLACK);		
		
		this.addKeyListener(board);
		
		nextButton.addActionListener(this);
		this.board.addKeyListener(board);
		this.getContentPane().add(nextButton, BorderLayout.NORTH);
		this.getContentPane().add(board, BorderLayout.CENTER);
		this.setSize(800,600);
		this.setVisible(true);
		*/
	}
	
	public void actionPerformed(ActionEvent e){
		//TODO
		
		this.dispose();
		this.board.endGame();
	}

}

